<include file="Public:header"/>
		<div id="content">
			<div id="content-header">
				<h1>栏目管理</h1>
				<div class="btn-group">
					<a href="{:U('Admin/Tag/tagList')}" class="btn btn-large" title="栏目列表"><i class="fa fa-tasks"></i></a>
				</div>
			</div>
			<div id="breadcrumb">
				<a href="index.html" title="回到首页" class="tip-bottom"><i class="fa fa-home"></i> 首页</a>
				<a href="#">栏目管理</a>
				<empty name="info['t_id']">
					<a href="#" class="current">添加栏目</a>
					<else />
					<a href="#" class="current">修改栏目</a>
				</empty>
			</div>
			<div class="container-fluid">
				<div class="row">
					<div class="col-xs-12">
						<div class="widget-box">
							<div class="widget-title">
								<span class="icon">
									<i class="fa fa-tags"></i>
								</span>
								<empty name="info['t_id']">
									<h5>添加栏目</h5>
								<else />
									<h5>修改栏目</h5>
									<input id="id" value="{$info.t_id}" type="hidden"/>
								</empty>
							</div>
							<div class="widget-content nopadding">
								<form action="#" method="get" class="form-horizontal">

									<div class="form-group">
                                        <label class="col-sm-3 col-md-3 col-lg-1 control-label">栏目名</label>
                                        <div class=" col-sm-9 col-md-9 col-lg-10">
                                        	<div class="input-group input-group-sm">
												<span class="input-group-addon"><i class="fa fa-tags"></i></span>
                                            	<input type="text" value="{$info.t_name}" class="form-control input-sm" placeholder="栏目名" id="name" />
                                            </div>
                                        </div>
                                    </div>

									<div class="form-group">
                                        <label class="col-sm-3 col-md-3 col-lg-1 control-label">上级分类</label>
                                        <div class="col-sm-9 col-md-9 col-lg-10">
											<select id="parent_id">
												<option value="0">顶级分类</option>
												{$tag_tree}

											</select>
                                        </div>
                                    </div>


									<div class="form-group">
										<label class="col-sm-3 col-md-3 col-lg-1 control-label">栏目描述</label>
										<div class="col-sm-9 col-md-9 col-lg-10">
											<textarea rows="5" class="form-control" id="remark">{$info.t_remark}</textarea>
										</div>
									</div>

									<div class="form-group">
                                        <label class="col-sm-3 col-md-3 col-lg-1 control-label">添加时间</label>
                                        <div class=" col-sm-9 col-md-9 col-lg-10">
                                        	<div class="row">
                                        		<div class="col-md-6">
                                            		<input type="datetime" <empty name="info['t_id']">value="{:date("Y-m-d H:i:s",time())}"<else />value="{$info.t_time|date='Y-m-d H:i:s',###}"</empty> class="form-control input-sm"  id="time"/>
                                            	</div>
                                            </div>
                                        </div>
                                    </div>

									<div class="form-group">
                                        <label class="col-sm-3 col-md-3 col-lg-1 control-label">添加人</label>
                                        <div class=" col-sm-9 col-md-9 col-lg-10">
                                        	<div class="input-group input-group-sm">
												<span class="input-group-addon"><i class="fa fa-user"></i></span>
                                            	<input type="text" <empty name="info['t_id']">value="{$Think.session.uname}"<else />value="{$info.t_root}"</empty> class="form-control input-sm" id="root"/>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group">
										<label class="col-sm-3 col-md-3 col-lg-1 control-label">显示</label>
										<div class="col-sm-9 col-md-9 col-lg-10">
											<label><input type="radio" name="show" value="0" <eq name="info['t_view']" value="0">checked</eq> /> Not show</label>
											<label><input type="radio" name="show" value="1" <eq name="info['t_view']" value="1">checked</eq> /> Show</label>
										</div>
									</div>

                                    <div class="form-group">
                                        <label class="col-sm-3 col-md-3 col-lg-1 control-label">排序</label>
                                        <div class=" col-sm-9 col-md-9 col-lg-10">
                                        	<div class="input-group input-group-sm">
												<span class="input-group-addon"><i class="fa fa-anchor"></i></span>
                                            	<input type="text" <empty name="info['t_id']">value="{$Think.config.SORT}"<else />value="{$info.t_sort}"</empty> class="form-control input-sm" id="sort"/>
                                            </div>
                                        </div>
                                    </div>

									<div class="form-group">
                                        <label class="col-sm-3 col-md-3 col-lg-1 control-label">发表自</label>
                                        <div class=" col-sm-9 col-md-9 col-lg-10">
                                        	<div class="input-group input-group-sm">
												<span class="input-group-addon"><i class="fa fa-user"></i></span>
                                            	<input type="text" <empty name="info['t_id']">value="{:getOs()}"<else />value="{$info.t_from}"</empty> class="form-control input-sm" id="from" />
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-3 col-md-3 col-lg-1 control-label">发表IP</label>
                                        <div class=" col-sm-9 col-md-9 col-lg-10">
                                        	<div class="input-group input-group-sm">
												<span class="input-group-addon"><i class="fa fa-user"></i></span>
                                            	<input type="text" <empty name="info['t_id']">value="{:get_client_ip()}"<else />value="{$info.t_ip}"</empty> class="form-control input-sm" id="ip" />
                                            </div>
                                        </div>
                                    </div>

									<div class="form-actions">
										<empty name="info['t_id']">
										<button type="button" class="btn btn-success btn-sm" id="addtag">存入数据库</button>
										<else />
										<button type="button" class="btn btn-success btn-sm" id="edittag">存入数据库</button>
										</empty>
										<button type="button" class="btn btn-danger btn-sm">取消</button>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	<include file="Public:footer"/>

    <script>
    	$(document).ready(function(){
			$('input[type=checkbox],input[type=radio]').iCheck({
		    	checkboxClass: 'icheckbox_flat-blue',
		    	radioClass: 'iradio_flat-blue'
			});
			$('select').select2();
		    $('.spinner').spinner();
		    $('#addtag').click(function(){
		    	var name = $('#name').val();
		    	var parent_id = $('#parent_id').val();
		    	var remark = $('#remark').val();
		    	var time = $('#time').val();
		    	var root = $('#root').val();
		    	var sort = $('#sort').val();
		    	var from = $('#from').val();
		    	var ip = $('#ip').val();
		    	var show = $('input[name="show"]:checked').val();
		    	if(!name){
		    		err("栏目标题不能为空!");
	    			return false;
		    	}else if(!remark){
		    		err("栏目描述不能为空!");
	    			return false;
		    		err("栏目操作时间不能为空!");
	    			return false;
		    	}else if(!root){
		    		err("栏目操作人不能为空!");
	    			return false;
		    	}else if(!sort){
		    		err("栏目排序不能为空!");
	    			return false;
		    	}else if(!from){
		    		err("来自不能为空!");
	    			return false;
		    	}else if(!ip){
		    		err("IP地址不能为空!");
	    			return false;
		    	}else if(!show){
		    		err("请选择是否显示!");
	    			return false;
		    	}
		    	$("#addtag").attr("disabled",true);
		    	$.ajax({
		    		type:"post",
		    		url:"/Admin/Tag/tagAdd",
		    		async:true,
		    		data:{"t_name":name,"parent_id":parent_id,"t_time":time,"t_sort":sort,"t_view":show,"t_remark":remark,"t_ip":ip,"t_from":from,"t_root":root},
		    		success:function(data){
		    			if(data.error==0){
							succ("添加栏目完成!",data.msg,"/Admin/Tag/tagList");
						}else{
							err(data.msg);
							$("#addtag").removeAttr('disabled');
						}
					},
					eerror:function(data){
						err("网络错误!");
						$("#addtag").removeAttr('disabled');
					}
		    	});
		    });
		    $('#edittag').click(function(){
		    	var id = $('#id').val();
		    	var name = $('#name').val();
		    	var parent_id = $('#parent_id').val();
		    	var remark = $('#remark').val();
		    	var time = $('#time').val();
		    	var root = $('#root').val();
		    	var sort = $('#sort').val();
		    	var from = $('#from').val();
		    	var ip = $('#ip').val();
		    	var show = $('input[name="show"]:checked').val();
		    	if(!name){
		    		err("栏目标题不能为空!");
	    			return false;
		    	}else if(!remark){
		    		err("栏目描述不能为空!");
	    			return false;
		    		err("栏目操作时间不能为空!");
	    			return false;
		    	}else if(!root){
		    		err("栏目操作人不能为空!");
	    			return false;
		    	}else if(!sort){
		    		err("栏目排序不能为空!");
	    			return false;
		    	}else if(!from){
		    		err("来自不能为空!");
	    			return false;
		    	}else if(!ip){
		    		err("IP地址不能为空!");
	    			return false;
		    	}else if(!show){
		    		err("请选择是否显示!");
	    			return false;
		    	}
		    	$("#edittag").attr("disabled",true);
		    	$.ajax({
		    		type:"post",
		    		url:"/Admin/Tag/tagEditH",
		    		async:true,
		    		data:{"t_id":id,"t_name":name,"parent_id":parent_id,"t_time":time,"t_sort":sort,"t_view":show,"t_remark":remark,"t_ip":ip,"t_from":from,"t_root":root},
		    		success:function(data){
		    			if(data.error==0){
							succ("修改栏目完成!",data.msg,"/Admin/Tag/tagList");
						}else{
							err(data.msg);
							$("#edittag").removeAttr('disabled');
						}
					},
					eerror:function(data){
						err("网络错误!");
						$("#edittag").removeAttr('disabled');
					}
		    	});
		    });
		});
    </script>
	</body>
</html>
